package o;

import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import com.huawei.appgallery.foundation.account.bean.UserSession;
import com.huawei.appmarket.service.externalapi.view.ThirdApiActivity;
import o.dio.c;

public class dzw extends dzr<Void, Void> {
    private Activity ˏ;

    protected /* synthetic */ Object ˎ(Object obj) {
        return ॱ((Void) obj);
    }

    public dzw(Activity activity) {
        super(false);
        this.ˏ = activity;
    }

    public static void ॱ(Activity activity, String str) {
        Logger.ˎ("GLOBAL_START_FLOW", " startPreFlow() ");
        dzv.ˊ(false);
        dzw o_dzw = new dzw(activity);
        o_dzw.ˏ(str);
        o_dzw.ˋ(null);
    }

    protected String ॱ() {
        return "TermsFlow";
    }

    protected Void ॱ(Void voidR) {
        Logger.ˎ("GLOBAL_START_FLOW", "TermsFlow process");
        boolean ˋ = diu.ˊ().ˋ();
        Logger.ˎ("GLOBAL_START_FLOW", "TermsFlow hasAgreeTerms =" + ˋ);
        ˎ();
        if (ˋ) {
            if (!UserSession.getInstance().isLoginSuccessful() || dir.ˋ().ˏ()) {
                ॱˊ();
            } else {
                Logger.ˋ("GLOBAL_START_FLOW", "TermsFlowisLoginSuccessful && !isSignedForUser");
                ˏॱ();
            }
        } else if (ccx.ˎ()) {
            ˋॱ();
        } else {
            ˏॱ();
        }
        return null;
    }

    private void ˋॱ() {
        Logger.ˏ("TermsFlow", "TermsFlow checkAccountLogin 1");
        Context context = this.ˏ;
        if (this.ˏ == null) {
            context = ContentManager.getInstant().getContext();
        }
        eod.ˏ(context, new eoi(this) {
            final /* synthetic */ dzw ˎ;

            {
                this.ˎ = r1;
            }

            public void ˎ(int i) {
                Logger.ˏ("TermsFlow", "TermsFlow checkAccountLogin 1: " + i);
                if (i == 0) {
                    ccx.ˊ(eqp.ॱ(), true);
                    this.ˎ.ॱ(true, true);
                    div.ॱ(true);
                    return;
                }
                this.ˎ.ˏॱ();
            }
        }, true);
    }

    private void ॱ(boolean z, boolean z2) {
        Logger.ˎ("GLOBAL_START_FLOW", "TermsFlow isAgree =" + z + ", isOOBE =" + z2);
        if (!z2 && z) {
            Logger.ˎ("GLOBAL_START_FLOW", ॱ() + " setSignedOnStartup true.");
            ˎ(true);
        }
        ͺ();
        if (this.ˏ != null && (this.ˏ instanceof dhn)) {
            ((dhn) this.ˏ).ˏ(0);
        }
        if (z) {
            ॱˊ();
            return;
        }
        dzl.ˋ("203", "CANCEL-PROTOCOL");
        ˋ();
    }

    private void ͺ() {
        if (this.ˏ.getRequestedOrientation() == -1) {
            try {
                this.ˏ.setRequestedOrientation(ˊॱ());
            } catch (Throwable e) {
                Logger.ˋ("GLOBAL_START_FLOW", "TermsFlow Exception.", e);
            }
        }
    }

    private int ˊॱ() {
        int i = 1;
        int i2 = this.ˏ.getResources().getConfiguration().orientation;
        if (1 != i2) {
            i = i2 == 0 ? 0 : -1;
        }
        i = ˋ(i);
        Logger.ˎ("GLOBAL_START_FLOW", "TermsFlow currentOrention=" + i);
        return i;
    }

    private int ˋ(int i) {
        int rotation = this.ˏ.getWindowManager().getDefaultDisplay().getRotation();
        if (rotation == 1) {
            return 0;
        }
        if (rotation == 2) {
            return 9;
        }
        if (rotation == 3) {
            return 8;
        }
        return i;
    }

    private void ॱˊ() {
        Logger.ˏ("TermsFlow", "TermsFlow checkAccountLogin");
        Context context = this.ˏ;
        if (this.ˏ == null) {
            context = ContentManager.getInstant().getContext();
        }
        eod.ˏ(context, new eoi(this) {
            final /* synthetic */ dzw ॱ;

            {
                this.ॱ = r1;
            }

            public void ˎ(int i) {
                boolean z = true;
                Logger.ˏ("TermsFlow", "TermsFlow checkAccountLogin: " + i);
                dzw o_dzw = this.ॱ;
                if (i != 1) {
                    z = false;
                }
                o_dzw.ˊ(z);
            }
        }, true);
    }

    private void ˊ(boolean z) {
        dzl.ˏ("hasLoginAccount", dgh.ॱ());
        Logger.ˏ("TermsFlow", "TermsFlow nextFlowConditionCheck deviceLogined=" + z);
        if (z) {
            nextFlow(new dzx(this.ˏ, ˊ()));
        } else {
            UserSession.getInstance().clear();
            eop.ॱ();
            CharSequence ॱ = eqp.ॱ();
            Logger.ˏ("TermsFlow", "TermsFlow homeCountry: " + ॱ);
            if (eqp.ᐝ()) {
                nextFlow(new dzs(this.ˏ, ˊ()));
            } else if (TextUtils.isEmpty(ॱ)) {
                nextFlow(new dzx(this.ˏ, ˊ()));
            } else {
                dzr o_dzs = new dzs(this.ˏ, ˊ());
                nextFlow(o_dzs);
                o_dzs.ˋ(true);
            }
        }
        ˊ(null);
    }

    private void ˏॱ() {
        Logger.ˏ("TermsFlow", "TermsFlowshowProtocol");
        diu ˊ = diu.ˊ();
        c anonymousClass4 = new c(this) {
            final /* synthetic */ dzw ॱ;

            {
                this.ॱ = r1;
            }

            public void ॱ(boolean z) {
                this.ॱ.ॱ(z, false);
            }
        };
        if (this.ˏ instanceof ThirdApiActivity) {
            ((ThirdApiActivity) this.ˏ).ॱˊ();
            ˊ.ॱ(this.ˏ, anonymousClass4);
            return;
        }
        ˊ.ˏ(this.ˏ, anonymousClass4);
    }
}
